<?php include '_init_.php';?>
<?php
$act = isset($_REQUEST['act'])?$_REQUEST['act']:'';

if($act == 'delete')
{
	if($_REQUEST['location'])
	{
		$dt = new DataTable(constant('DB_TABLE_LOCATION'));
		foreach($_REQUEST['location'] as $tmpId)
		{
			$dt->remove(intval($tmpId));
		}
	}
}
?>
<?php include 'page_header.php';?>
<div id="main"><!-- start #main //-->
<div id="tita"> <!-- start #tita //-->
<?php define('ADMIN_NAVIGATOR_ITEM','預約門市管理');?>
<?php include 'navigator_admin.php';?>
<?php define('ADMIN_MENU_CURRENT_ITEM','預約門市管理');?>
<?php include 'admin_menu.php';?>

<script language="javascript">
function edit_to_edit() {
	var url = '';
	if($('#location_container input[type=checkbox][checked]').length == 1)
	{
		url = "backstagedi.php?act=edit&id="+$('#location_container input[type=checkbox][checked]').val();
		rAlert(url, null, "預約門市管理", 704, 160);
	}else{
		alert('請選擇一個預約門市');
		return false;
	}
	
}
function edit_to_new()
{
	var url = 'backstagedi.php?act=new';
	rAlert(url, null, "預約門市管理", 704, 160);
}
</script>

<div class="clearfix" id="mainf"><!-- start #mainf //-->
<?php
$dt = new DataTable(constant('DB_TABLE_LOCATION'));
$data_list = $dt->get_list();
?>
<script language="javascript">
function delete_location()
{
	if(confirm('Delete selected')){document.forms['form_location'].submit();} 
	return false;
}
</script>
<form name="form_location" method="post">
<input type="hidden" name="act" value="delete"/>
<div class="mainf-3" id="location_container">
<ul>
      <li class="maina-1i">
        預約門市管理</li>
    	<?php foreach($data_list as $tmpData):?>
    		 <li class="maina-1a"><input type="checkbox"  name="location[]" value="<?php echo $tmpData['id'];?>">&nbsp;<?php echo $tmpData['name'];?></li>
    	<?php endforeach;?>
        <li class="maina-1d">
        <a onclick="javascript:edit_to_new();return false;" href="#"><img width="60" height="17" src="images/backstage-btn-5.gif"></a>
        <a onclick="javascript:edit_to_edit();return false;" href="#"><img width="60" height="17" src="images/backstage-btn-6.gif"></a>
        <a href="#" onclick="return delete_location();"><img width="60" height="17" src="images/backstage-btn-7.gif"></a>
        </li>
       </ul>
</div>
</form>

</div><!-- end #mainf //-->
</div><!-- end #tita //-->
</div><!-- end #main //-->
<?php include 'page_footer.php';?>